<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions" 
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
  targetNamespace="Examples">

 <process id="testProcess" isExecutable="true">

  <startEvent id="start" />

  <sequenceFlow sourceRef="start" targetRef="bookHotel" />

  <serviceTask id="bookHotel" camunda:expression="${true}">
    <multiInstanceLoopCharacteristics isSequential="true">
      <loopCardinality>5</loopCardinality>
    </multiInstanceLoopCharacteristics>
  </serviceTask>

   <boundaryEvent id="compensateBookHotelEvt" name="Boundary event" attachedToRef="bookHotel">
    <compensateEventDefinition />
   </boundaryEvent>  

   <serviceTask id="undoBookHotel" isForCompensation="true"
    camunda:class="org.camunda.bpm.engine.test.bpmn.event.compensate.helper.UndoService">
    <extensionElements>
     <camunda:field name="counterName" stringValue="undoBookHotel" />

      <camunda:executionListener event="start">
        <camunda:script scriptFormat="groovy">
          execution.setVariable('start', start + 1);
        </camunda:script>
      </camunda:executionListener>

     <camunda:executionListener event="end">
        <camunda:script scriptFormat="groovy">
          execution.setVariable('end', end + 1);
        </camunda:script>
      </camunda:executionListener>

    </extensionElements>

   </serviceTask> 

  <sequenceFlow sourceRef="bookHotel" targetRef="throwCompensate" />

  <intermediateThrowEvent id="throwCompensate">
      <compensateEventDefinition activityRef="bookHotel" />
  </intermediateThrowEvent>

  <sequenceFlow sourceRef="throwCompensate" targetRef="wait" />

  <receiveTask id="wait"></receiveTask>

  <sequenceFlow sourceRef="wait" targetRef="end" />

  <endEvent id="end" />

  <association associationDirection="One" sourceRef="compensateBookHotelEvt" targetRef="undoBookHotel" />
 </process>

</definitions>
